 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>php</title>
</head>
    <?php

// 请求连接
$url = 'https://api.test.rentwell2021.com/api-web/api/gateway/call/credit';
// 业务请求参数的集合

    $biz_content=[];
    $biz_content['applyOrderId']='SH202312141815152070111';
    $biz_content['idCardNo']='123';
    $biz_content['name']='123';
    $biz_content['telephone']='17779146888';
    $biz_content['photoFront']='https://jumizu.9f.ink/attachment/images/1/2023/12/VcMVmE80zH0vDl0CcCDCCB0VLlRvYDCc0tjPcHejc0MYm0VP8lje.png';
    $biz_content['photoBack']='https://jumizu.9f.ink/attachment/images/1/2023/12/uJetlOMQ57EsT5m9Ot9EM99TLi9Jj5mL7k5L73Kb7sJ3gMkeM5j9.png';
    $biz_content['userAuthProtocol']='https://smlt.esign.cn/NatwhN9';
    $biz_content['userAuthSignTime']=date('Y-m-d H:i:s');
    $biz_content['pbcCreditAuth']='https://smlt.esign.cn/NatwhN9';
    $biz_content['pbcAuthSignTime']=date('Y-m-d H:i:s');
    $biz_content['productType']='v011';
    $biz_content['scc']='91330381MAC65FWH5X';
    $biz_content['companyName']='瑞安市诺明网络科技有限公司';
//$biz_content = '{
//            "applyOrderId":"SH202312141815152070111",
//            "idCardNo":"身份证号xxx",
//            "name":"陈**",
//            "telephone":"17779146888",
//            "photoFront":"https://jumizu.9f.ink/attachment/images/1/2023/12/VcMVmE80zH0vDl0CcCDCCB0VLlRvYDCc0tjPcHejc0MYm0VP8lje.png",
//            "photoBack":"https://jumizu.9f.ink/attachment/images/1/2023/12/uJetlOMQ57EsT5m9Ot9EM99TLi9Jj5mL7k5L73Kb7sJ3gMkeM5j9.png",
//            "userAuthProtocol":"https://smlt.esign.cn/NatwhN9",
//            "userAuthSignTime":"2023-12-14 18:17:03",
//            "pbcCreditAuth":"https://smlt.esign.cn/NatwhN9",
//            "pbcAuthSignTime":"2023-12-14 18:17:03",
//            "productType":"v011",
//            "scc":"91330381MAC65FWH5X",
//            "companyName":"瑞安市诺明网络科技有限公司"
//        }';
    $biz_content_josn=json_encode($biz_content);
// 需要加密的数据 = 业务请求合集，拼接当前时间戳
$biz_content_res = $biz_content_josn.time();

// 私钥数据
$privateKey =
    '-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCdsPUhJC+/amDl
zqkEfoH/veO8ANPs/N0Qggfo7PoKWDAho2s/Obge224ZtNIbGONOWyyPweYi8sOw
c+wV2BUa1Fg+3ApU5qWBdRyVX/tAMjOE5V16iNsIIepPZQ4s8j1zQPxatMJTVvJq
IchPomWWGRaOWlxwZt9IdyntcrI1JRLDyfEbdsHCrb5id3pmPvPGIG1Wz7IpVd2J
/cN3J4bFbSXDAxy5c9hWWoVfKmHKEtUnh1PCI37+BemCGgCKb9rwiHBXC6eiFCNW
s1shzHag39g1kpveogoq3/zHgHfsDYPkNRg00PMk0Zf1bSC+RK+oE3PnJ5SsicjR
ahHvy5PrAgMBAAECggEAPZF94/aw/deXBaLusuaB80w8wobAN+NynKNoWzVLWwab
pEad9Q2gKcwa7MaA0juhZFKMz4QxSqvmY9qe7thzRQpref+HuSZksGr9QgU7oBD5
tIWpPdJ5Um+LgHxAUKQ0Ae/5l6DDzq4/79hI0W7iovwgpmv5c5l2zGBaam9BzSWT
jLrgF4Zp42R1MNQlysc36Yq/ehEu/ObX/44aKk0F0sebRt0M47S+F8q3XBOveoZp
4ySzDYkVgVxSi1eYBmuxjgWWflK/4TaNPl9T5x0A+2WOEkbbMoPDBoGymbuEm7f3
7+DjBqXOWXU+zkYdK3RldtLxJLzXKuALzVjFc6c+QQKBgQDJTxrU/PxHHzLu+QLg
cr8HJd8gtPvYDzGTMA8mvLEMqxInsqf5Bi5bc3gM5wYDSfsM6mq2RtjSynoo7ckl
6m6iniuVLFtsq0ZT1SWCPwt4LEH9ORl2lutC0nA/xh/Q9ptLwOCa/y3oaDtg3m2V
cNSApxrsZcpmJVU5E7Tpu4t4cwKBgQDIiETaEGgi5j9gYxQ//+94Pmwwc2YwpE7m
wrhenX9R4tXKGEbFuoncpVPkaXb46R+KrJ5BBBMOYgeH/wZD7yoo0TsTO+JP0HEQ
Ac75mMAIVg6S1YaTwhoMwVvCA2/0uQ1V35wsdNF0J0flVhk94/keXSFEzBlkE3qb
iFtd8e6wqQKBgDZcDxHOks0dxqIzSayUL7NdbagmVw9b4vYs9xptv519IHTp0GP1
YFU/k/5f8Aa5VnqBXnmEHg6lsGEW/McpS+DLt1cb2EA66829c9h877rusI8ReSfF
zxeHPdpqxLKntP26wqv4Fkx4wPgCeDLveeKXvTRytDnrAN1dze+DvkCzAoGATMb/
tY36kQIe2cSViDtxcFRWD+bfBVijbO64sGEU0kFLIWlSD3pwNi6GhDls97gp/2o/
3Ry2PxeBUqxttazoM2CIgcC30V85KqvGlwHI5GguhEGEmSYD20Zc31d5kfUYCfzn
So4fc51mhYQFfhC+3MVDa5fJUOu0UcBPWxS6EqECgYB36n4SI/Fh99jbyoNSNso2
R0dYAqMGmvBTg9IAllo07yWbXTE8aQ0/vms/N4Q8Og+xOZOneVfrTphJr/t7oMkc
5FPghyfzeAW7CaW0tsz1CFahs8KMNnxl7Q5TtknBCD1mlgdW6SdVhGkqHsrFEYni
mHGgDCKjPi/5NYHy1ODJPQ==
-----END PRIVATE KEY-----';
// 获取私钥资源
$key = openssl_get_privatekey($privateKey) ;
// 通过私钥对数据进行数字签名
openssl_sign($biz_content_res, $signature, $key, "sha256WithRSAEncryption");
$sign = base64_encode($signature);
var_dump($sign);
$data = [
    'app_code' => '3392def305d582053d368a5737821e8b',
    'method' => 'apply_order_query',
    'timestamp' => time(),
    'version' => '1.0.0',
    'biz_content' => $biz_content_josn,
    'sign' => $sign,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,['Accept: application/json','User-Agent: */*','Content-Type: application/json']); //设置header头
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data,true));
$output = curl_exec ($ch);
curl_close ($ch);
var_dump($output);
return json_decode($output);?>
</html>
